import 'package:flutter/material.dart';
import 'package:tender_flutter/constant/theme_colors.dart';
import 'package:tender_flutter/manager/login_manager.dart';
import 'package:tender_flutter/router/router.dart';
import 'package:tender_flutter/utils/screen_adaper.dart';

class LoginDialog extends StatelessWidget {
  final String title;
  final String content;

  const LoginDialog({Key key, this.content, this.title}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
        child: _initBody(context),
        onWillPop: () {
          LRouter.navigatorCtx(context).pop();
          return Future.value(false);
        });
  }

  Widget _initBody(BuildContext context) {
    return Center(
        child: Container(
      width: ScreenAdapter.width(600),
      padding: EdgeInsets.only(top: ScreenAdapter.height(40)),
      decoration: BoxDecoration(
          color: ThemeColors.colorWhite,
          borderRadius: BorderRadius.circular(ScreenAdapter.width(15))),
      child: Column(mainAxisSize: MainAxisSize.min, children: [
        Text(title ?? "温馨提示",
            style: TextStyle(
                color: ThemeColors.colorType2,
                fontSize: ScreenAdapter.sp(36),
                fontWeight: FontWeight.bold)),
        Container(
          padding: EdgeInsets.symmetric(
              vertical: ScreenAdapter.height(50),
              horizontal: ScreenAdapter.width(30)),
          child: Text(content ?? "您的登录信息已过期，请重新登录",
              style: TextStyle(
                  color: ThemeColors.colorType2,
                  fontSize: ScreenAdapter.sp(30),
                  fontWeight: FontWeight.w600)),
        ),
        Divider(height: 1, color: ThemeColors.colorType49),
        Container(
            height: ScreenAdapter.height(90),
            width: ScreenAdapter.width(180),
            child: FlatButton(
                onPressed: () {
                  LRouter.navigatorCtx(context).pop();
                  LoginManager.login();
                },
                child: Text("去登录",
                    style: TextStyle(
                        color: ThemeColors.colorType6,
                        fontSize: ScreenAdapter.sp(32)))))
      ]),
    ));
  }
}
